package cn.yexiaofeng.bookmanager.controller;


import cn.yexiaofeng.bookmanager.beans.LendList;
import cn.yexiaofeng.bookmanager.service.LendListService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletRequest;
import java.util.List;

/**
 * 借阅
 */
@Controller
public class LendListController {

    @Autowired
   LendListService lendListService;


    @GetMapping(value = "/getLend")
    public  String lendList(ServletRequest request){
        String curr=request.getParameter("curr");
        String pageSize=request.getParameter("pageSize");
        if (curr==null||curr==""){
            curr="1";
        }
        if (pageSize==null||pageSize==""){
            pageSize="3";
        }
        List<LendList> lendInfo = lendListService.getLendInfo(curr, pageSize);
        PageInfo pageInfo=new PageInfo(lendInfo,3);//页面数
        request.setAttribute("lenInfos",pageInfo);
        return "lendInfo";
    }


}